<?php
namespace Admin\Factory\Form;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Admin\Form\CreateUserForm;
use Admin\Form\CreateUserFormFilter;
use User\Validator\NoRecordExists;

class CreateUserFormFactory implements FactoryInterface
{
    public function createService(ServiceLocatorInterface $serviceManager)
    {
        $options = $serviceManager->get('user_module_options');

        $userMapper = $serviceManager->get('admin_user_mapper');
         
        $emailValidator = new NoRecordExists(array(
            'mapper' => $userMapper,
            'key' => 'email',
        ));
        
        $roleMapper = $serviceManager->get('admin_role_mapper');
                
        //$inputFilter = new CreateUserFormFilter($emailValidator , $options);
        $form = new CreateUserForm('register' , $options , $roleMapper);
        
        //$form->setInputFilter($inputFilter);
        return $form;
    }
} 